﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TestWService
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        long[] toc = new long[] { -4, -5, 0, 1, -6, 3, 4, 5, 6, 7, 46, 47, 92, 2, -3, -2, -1, -92, -47, -46, -7, -93, 93, -9223372036854775808, -2147483648, 2147483647, 9223372036854775807 };
        string[] words = new string[] {"cat","trailing space ","Bang!","","cat and dog","two  spaces"," leading space","Capital","This is a snark: ⸮","P!u@n#c$t%u^a&t*i(o)n","detartrated kayak detartrated","¿Qué?","  S  P  A  C  E  Y  ","!B!A!N!G!S! "};
        List<int[]> shap = new List<int[]>()
        {
           new int[]{0,0,0}, new int[]{1,1,0}, new int[]{1,1,2}, new int[]{1,0,1}, new int[]{2,1,1}, new int[]{1,2,3}, new int[]{1,1,2147483647},
 new int[]{1,1,1}, new int[]{2,2,2}, new int[]{2147483647,2147483647,2147483647}, new int[]{2,2,3}, new int[]{2,3,2}, new int[]{3,2,2},
 new int[]{2,3,4}, new int[]{3,4,2}, new int[]{4,2,3}, new int[]{4,3,2}, new int[]{1,2,1}, new int[]{-2147483648,-2147483648,-2147483648},
 new int[]{-1,-1,-1}, new int[]{-1,1,1}, new int[]{1,-1,1}, new int[]{1,1,-1}, new int[]{0,1,1}, new int[]{2147483647,2147483647,2147483647}        };

        private void button1_Click(object sender, EventArgs e)
        {
            //local
            // ServiceReference2.RedPillClient lo = new ServiceReference2.RedPillClient("BasicHttpBinding_IRedPill");

            //spa
            ServiceReference3.RedPillClient me = new ServiceReference3.RedPillClient("BasicHttpBinding_IRedPill3");

            //readify
            ServiceReference4.RedPillClient cc = new ServiceReference4.RedPillClient("BasicHttpBinding_IRedPill4");

            DateTime tt = DateTime.Now;


            foreach (long g in toc)
            {
                long a = 0, b = 0;
                string Ma = "", Mb = "";


                try
                {
                    a = me.FibonacciNumber(g);
                }
                catch (Exception exp)
                {
                    Ma = exp.Message;
                }

                try
                {
                    b = cc.FibonacciNumber(g);
                }
                catch (Exception exp)
                {
                    Mb = exp.Message;
                }

                if (a != b)
                    MessageBox.Show(g + " FibonacciNumber is " + b);


                if (Ma != Mb)
                    MessageBox.Show(Mb);

            }

            foreach (string s in words)
            {
                if (me.ReverseWords(s) != cc.ReverseWords(s))
                    MessageBox.Show(s + "- ReverseWords is -" + cc.ReverseWords(s));
            }

            foreach (int[] ia in shap)
            {
                if (me.WhatShapeIsThis(ia[0], ia[1], ia[2]).ToString().ToLower() != cc.WhatShapeIsThis(ia[0], ia[1], ia[2]).ToString().ToLower())
                    MessageBox.Show(ia[0] + "," + ia[1] + "," + ia[2] + "- WhatShapeIsThis is " + cc.WhatShapeIsThis(ia[0], ia[1], ia[2]));
            }

            for (int i = 0; i < 5; i++)
            {
                string ss = cc.ReverseWords("P!u@n#c$t%u^a&t*i(o)n");
                ServiceReference4.TriangleType tdt = cc.WhatShapeIsThis(1, 2, 1);
                long l = cc.FibonacciNumber(-5);
            }

            label1.Text = DateTime.Now.Subtract(tt).TotalSeconds.ToString();
        }


        public string  WhatShapeIsThis(int a1, int b1, int c1)
        {
            long a = a1;
            long b=b1;
            long c = c1;

            if (a < 1 || b < 1 || c < 1)
                return "Error";
            else if (a + b <= c || b + c <= a || c + a <= b)
                return "Error";  // Sides can't possible connect -- illegal
            if (a == b && b == c)
                return "Equilateral";
            else if (a == b || b == c || a == c)
                return "Isosceles";
            else
                return "Scalene";
        }
    }
}
